<template>
	<view class="container" :style="{minHeight:$height()}">
		<view class="item" v-for="(item,index) in list" :key="index">
			<view class="topBox">
				<view class="king-flex" style="flex: 9;">
					<image :src="`../../static/Icon/${getSuffix(item.image)}.png`" style="width:50rpx;height:50rpx;"></image>
					<view class="txt">
						{{item.company.name}}{{item.name}}
					</view>
				</view>
				<view class="look" @click="openFile(item.image)">
					查看
				</view>
			</view>
			<view class="buttomBox">
				<view class="tateBox">
					<view class="tate">
						上传时间：{{item.createDate}}
					</view>
				</view>
			</view>
		</view>
		
		
		<image v-if="list.length == 0" src="@/static/image/empty.png" mode="widthFix" class="is-empty"></image>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				type:0,
				folderName:""
			}
		},
		onLoad(options) {
			this.type = options.type
			this.folderName = options.folderName
		},
		onShow() {
			this.getUser()
		},
		methods: {
			getSuffix(url){
				let suffix = this.$utils.getFileSuffix(url)
				let str = 'pdf'
				if(suffix == 'jpg' || suffix == 'png' || suffix == 'jpeg' || suffix == 'gif'){
					str = 'image'
				}else if(suffix == 'xlsx' || suffix == 'xls'){
					str = 'xlsx'
				}else{
					str = suffix
				}
				return str
			},
			getUser() {
				this.$axios.request(this.$api.getCompanyResourceRes, "GET",{
					type:this.type,
					folderName:this.folderName
				}).then((val) => {
					this.list = val.data
				})
			},

			openFile(url) {
				let suffix = this.$utils.getFileSuffix(url)
				let urlPath = this.$axios.interfaceUrl() + url
				if(suffix == 'jpg' || suffix == 'png' || suffix == 'jpeg' || suffix == 'gif'){
					uni.previewImage({
						current:0,
						urls:[urlPath]
					})
				}else if(suffix == 'txt'){
					this.$next(`/pages/index/webView?url=${this.$utils.encryption(urlPath)}`)
				}else{
					this.$utils.downLoad(urlPath)
				}
				
			}
		}
	}
</script>

<style>
	.container {
		background-color: #F0F2F5;
	}

	.item {
		display: flex;
		justify-content: space-between;
		flex-direction: column;
		width: 100%;
		/* height: 148rpx; */
		background-color: #FFFFFF;
		padding: 16rpx 35rpx;
		margin-top: 16rpx;
	}

	.topBox,
	.buttomBox {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
	}

	.txt {
		margin-left: 10rpx;
		font-size: 28rpx;
		line-height: 50rpx;
		flex: 9;
		color: #333333;
		opacity: 1;
	}

	.look {
		flex: 1;
		height: 40rpx;
		background-color: #2E6ADF;
		opacity: 1;
		border-radius: 4rpx;
		font-size: 24rpx;
		font-weight: 300;
		line-height: 40rpx;
		padding: 0 26rpx;
		color: #FFFFFF;
		opacity: 1;
	}

	.dowload {
		height: 40rpx;
		border-radius: 4rpx;
		font-size: 24rpx;
		font-weight: 300;
		line-height: 40rpx;
		padding: 0 26rpx;
		color: #2E6ADF;
		opacity: 1;
		background-color: #FFFFFF;
		border: 1rpx solid #2E6ADF;
		border-radius: 4rpx;
	}

	.tateBox {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		height: 100%;
		margin-top:10rpx;
		font-size: 24rpx;
		font-weight: 300;
		color: #222222;
	}

	.more {
		font-size: 24rpx;
		text-align: center;
		font-weight: 300;
		color: #BBBBBB;
		opacity: 1;
		margin: 24rpx auto 116rpx;
	}
</style>